home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / std / c / 430 < prev    next >
Text File  |  1996-08-06  |  3KB  |  62 lines

  1. Path: newshost.lanl.gov!tanmoy
  2. From: tanmoy@qcd.lanl.gov (Tanmoy Bhattacharya)
  3. Newsgroups: comp.std.c
  4. Subject: Re: fast block zeroing, how defined?
  5. Date: 13 Feb 1996 19:43:02 GMT
  6. Organization: Los Alamos National Laboratory
  7. Message-ID: <TANMOY.96Feb13124302@qcd.lanl.gov>
  8. References: <4fqaj4$2qu@fu-berlin.de>
  9. NNTP-Posting-Host: qcd.lanl.gov
  10. Mime-Version: 1.0
  11. Content-Type: text
  12. In-reply-to: axl@zedat.fu-berlin.de's message of Tue, 13 Feb 1996 15:29:21 GMT
  13.  
  14. In article <4fqaj4$2qu@fu-berlin.de> axl@zedat.fu-berlin.de (Axel
  15. Thimm) writes: 
  16. <snip>
  17.    in <string.h> there is (at least in GNU C) a function
  18.    void bzero(void *pointer, int length);
  19.    which fills the memory from pointer to pointer+length-1 with zeros. This
  20.    can be used for fast array zeroing, but I do not know how well this is
  21.    defined in ANSI C.
  22.  
  23.    [Q1]    Is bzero part of ANSI?
  24.  
  25. No.
  26.  
  27.    [Q2]    Are the representation of zeros in intergral types defined
  28.        as multiple "char" zeros? (This is true in all the implementations
  29.        I know of, but it should be also defined in the standard that way)
  30.  
  31. All the significant bits of zero of an integral type, except for the
  32. highest, must be zero. Unfortunately, it has been decided that not all
  33. bits are significant. I conclude that some of them can be used for
  34. parity checks, and I conclude the top bit being zero (with others
  35. being zero) can result in an invalid value. I am not familiar enough
  36. with the standard to guarantee my conclusions have any merit: but I
  37. would like to know why they are wrong if they are.
  38.  
  39. Provisionally, I would not memset or calloc on non-character integral
  40. types if absolute adherence to the standard were a criterion.
  41.  
  42.    [Q3]    What does the standard say about float representations of zero?
  43.  
  44. Nothing.
  45.  
  46.        What should the casting to a char[sizeof(float)] and vice versa do?
  47.  
  48. You can't cast to an array type.
  49.  
  50.        (In case that 0.0f casted to a char array (or the pointers thereof, to
  51.        be precise) returns {0, 0, 0, 0} (in a 4-byte float, i.e.
  52.        sizeof(float)==4) then bzero could be used to zero float arrays, too.)
  53.  
  54. Cheers
  55. Tanmoy--
  56. tanmoy@qcd.lanl.gov(128.165.23.46) DECNET: BETA::"tanmoy@lanl.gov"(1.218=1242)
  57. Tanmoy Bhattacharya O:T-8(MS B285)LANL,NM87545 H:#9,3000,Trinity Drive,NM87544
  58. Others see <gopher://yaleinfo.yale.edu:7700/00/Internet-People/internet-mail>,
  59. <http://alpha.acast.nova.edu/cgi-bin/inmgq.pl>or<ftp://csd4.csd.uwm.edu/pub/
  60. internetwork-mail-guide>. -- <http://nqcd.lanl.gov/people/tanmoy/tanmoy.html>
  61. fax: 1 (505) 665 3003   voice: 1 (505) 665 4733    [ Home: 1 (505) 662 5596 ]
  62.